<template>
	<view class="body">
		
		<view class="container">
			<view class="reportView ">
				<view class="container-1"  :data-index="index" v-for="(i, index) in list">
					<view class="left">
						<view class="top">
							<text class="title blue">{{i.name}}</text>
							<text class="orange">标识：{{i.code}}</text>
						</view>
						<view class="bottom">
							<text>创建时间:{{parseTime(i.createTime,'{y}-{m}-{d}')}}</text>
							<text>分类:{{i.type}}</text>
							<text :class="i.status == 0?'green':'red'">状态：{{i.status == 0?'开启':'关闭'}}</text>
						</view>
					</view>
					<view class="right" @click="open(i)">
						<text class="dot"></text>
						<text class="dot"></text>
						<text class="dot"></text>
					</view>
					<!-- <view class="update-1" @click="update(i.id)">
						修改
					</view>
					<view class="delete-1" @click="delData">
						删除
					</view> -->
				</view>
			</view>
		</view>
		<view class="topTitle">
			<text @tap="toAdd">新增角色</text>
		</view>
		<uni-popup ref="popup" type="bottom">
			<view class="popup">
				<text @click="menuRole">菜单权限</text>
				<text @click="dataRole">数据权限</text>
				<text @click="update">修改</text>
				<text  class="del">删除</text>
				<text class="cancel" @click="close">取消</text>
			</view>
		</uni-popup>
	</view>
	
</template>
<script>
	import { getRoleList } from '@/api/system/system.js'
	import {parseTime } from '@/utils/ruoyi'
	export default{
		data(){
			return{
				list:[],
				pageForm:{
					pageNo:1,
					pageSize:10,
				},
				active:null,
				parseTime
			}
		},
		created() {
			 this.getList()
		},
		methods:{
			open(e){
				this.active=e
				console.log(e)
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.popup.open('bottom')
			},
			close() {
				this.$refs.popup.close()
			},
			getList(){
				getRoleList(this.pageForm).then(res=>{
					this.list= res.data.list
				})
			},
			toAdd(){
				this.$tab.navigateTo(`/pages/system/role/addRole`)
			},
			
			//删除方法
			delData() {
				console.log("删除")
				uni.showModal({
					title: '提示',
					content: "确认删除该职位？",
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			update(){
				this.$tab.navigateTo(`/pages/system/role/addRole?id=` + this.active.id)
				this.close()
			},
			menuRole(){
				this.$tab.navigateTo(`/pages/system/role/menuRole?id=` + this.active.id)
				this.close()
			},
			dataRole(){
				this.$tab.navigateTo(`/pages/system/role/dataRole?id=` + this.active.id)
				this.close()
			}
		}
	}
</script>

<style lang="scss">
	
	.container{
		background-color: #fff;
		height:100vh;
		padding-top: 20px;
		.reportView{
			width: calc(100% - 80rpx);
			margin: 0 auto;
			font-size: 14px;
			font-family: Inter-Thin, Inter;
			
		}
		
		.container-1 {
			margin-top: 26rpx;
			margin-bottom: 20upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding:10px 5px;
			border-bottom:  1px solid #E1E1E1;
			
			.left{
				width: 92%;
				text{
					line-height: 30px;
					font-size: 12px;
					font-family: Inter-Regular, Inter;
					font-weight: 400;
					color: #5E5E5E;
				}
				.top{
					display: flex;
					justify-content: flex-start;
					text{
						margin-right: 10px;
					}
					
				}
				.bottom{
					display: flex;
					justify-content: space-between;
					margin-top: 10px;
					padding-right: 20px;
					text{
						margin-right: 8px;
						font-size: 12px;
					}

				}
				.blue{
					color: #508CFF;
				}
				.red{
					color: #F26D6D;
				}
				.green{
					color: #50B987;
				}
				.orange{
					color: #FF9A50;
				}
				
			}
			.right{
				display: flex;
				.dot{
					width: 5px;
					height: 5px;
					background: #A3A3A3;
					opacity: 1;
					margin-right: 5px;
					border-radius: 5px;
				}
			}
		}
	}
	.topTitle{
		color: #fff;
		width: 100px;
		height: 40px;
		font-size: 14px;
		line-height: 40px;
		background: #508CFF;
		border-radius: 5px 5px 5px 5px;
		position: fixed;
		bottom: 50px;
		left: 36%;
		text-align: center;
	}
	.popup{
		height: 157px;
		background: #FFFFFF;
		text{
			line-height: 50px;
			display: block;
			text-align: center;
			font-family: Roboto-Regular, Roboto;
			font-weight: 400;
			color: #000000;
			font-size: 16px;
		}
		.cancel{
			color: #F26D6D;
		}
	}
</style>